define(["jquery"],function($){
	function RegisterModal(){
		this.createDom();
		this.addListener();
	}
	RegisterModal.Html=`<div class="modal fade" id="registerModal" tabindex="-1" role="dialog" aria-labelledby="myRegisterModalLabel">
	  <div class="modal-dialog" role="document">
	    <div class="modal-content">
	      <div class="modal-header">
	        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
	        <h4 class="modal-title" id="myRegisterModalLabel">注册</h4>
	      </div>
	      <div class="modal-body">
	        <form class="form-register">
	          <div class="form-group">
	            <label for="username-r">用户名</label>
	            <input type="text" class="form-control" id="username-r" name="username" placeholder="请输入用户名">
	          </div>
	          <div class="form-group">
	            <label for="password-r">密码</label>
	            <input type="password" class="form-control" id="password-r" name="password" placeholder="请输入密码">
	          </div>
	          <div class="form-group">
	            <label for="password-again">确认密码</label>
	            <input type="password" class="form-control" id="password-again" placeholder="请输入密码">
	          </div>
	          <div class="form-group">
	            <label for="email">邮箱</label>
	            <input type="email" class="form-control" id="email" name="email" placeholder="请输入邮箱">
	          </div>
	        </form>
	      </div>
	      <div class="modal-footer">
	        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
	        <button type="button" class="btn btn-primary btn-reg">注册</button>
	      </div>
	    </div>
	  </div>`;
	$.extend(RegisterModal.prototype,{
		createDom(){
			$(RegisterModal.Html).appendTo("body");
		},
		addListener(){
			$(".btn-reg").on("click",this.registerHandel);
		},
		registerHandel(){
			$.post("/api/users/register",$(".form-register").serialize(),(data)=>{
				console.log(data);
			});
		}
	});
	return new RegisterModal();
});